import Mock from "mockjs2";
import { builder, getBody } from "../util";

const findNewWlVersionAndSysInfo = () => {
  return builder({
    roles: ["Admin"],
    permissions: {
      menus: [
        {
          path: "/dashnbord",
          name: "dashnbord",
          meta: {
            title: "交通态势",
            icon_class: "itsIcons",
            icon: "&#xe90d;",
          },
          children: [
            {
              path: "home",
              name: 'dashnbord_plaHome',
              address: "/demo/tree/index",
              meta: {
                title: "交通指数",
                icon_class: "material-icons",
                icon: "&#xe2c7;",
                keepAlive: true,
              },
            },
          ],
        },
      ],
      roleIds: ["8a948b446f82e6ed016f83d446a40009"]
    },
    permissionOperates: [
      {
        url: "/system/user/roles",
        permissionList: ["rolePermission:Access", "rolePermission:add", "rolePermission:edit", "rolePermission:delete"]
      },
      {
        url: "/system/user/menu",
        permissionList: ["menu:add", "menu:edit", "menu:delete", "menu:submenu"]
      },
      {
        url: "/system/user/management",
        permissionList: ["user:add", "user:delete", "user:edit"]
      },
      {
        url: "/carqc/emphasisCar",
        permissionList: ["carqc_focuscar_operate:findByPage"]
      },
      {
        url: "/carqc/carLocaltion",
        permissionList: ["carqc_carTraffic_operate:exportToExcel"]
      },
      {
        url: "/auditcontrol/trucksSupervise/whiteList",
        permissionList: ["carqc_wfw_operate:updateById", "carqc_wfw_operate:delete", "carqc_wfw_operate:findByPage", "carqc_wfw_operate:exportToExcel", "carqc_wfw_operate:batchImport", "carqc_wfw_operate:save"]
      },
      {
        url: "/auditcontrol/trucksSupervise/warning",
        permissionList: ["carqc_bigCar_operate:passdata", "carqc_bigCar_operate:findByPage"]
      },
      {
        url: "/auditcontrol/trucksSupervise/registerQuery",
        permissionList: ["carqc_wfw_operate:itcFindByPage", "carqc_wfw_operate:itcFindByHphmAHpzl"]
      },
      {
        url: "/auditcontrol/redWhite",
        permissionList: ["carqc_redWhiteList_operate:delete", "carqc_redWhiteList_operate:findById", "carqc_redWhiteList_operate:addOrUpdate", "carqc_redWhiteList_operate:findByPage"]
      },
      {
        url: "/auditcontrol/dstvehpass/trafficStatistics",
        permissionList: ["carqc_trafficStatistics_operate:exportTrafficFlowByHour", "carqc_trafficStatistics_operate:queryAndStatisticsTrafficFlowByHour"]
      },
      {
        url: "/auditcontrol/dstvehpass/trafficAnalysis",
        permissionList: ["carqc_ioFlowAnalysis_operate:exportFlowAnalysis", "carqc_ioFlowAnalysis_operate:findFlowAnalysis"]
      },
      {
        url: "/auditcontrol/dstvehpass/track",
        permissionList: ["carqc_trackbk_operate:findById", "carqc_trackbk_operate:changeBkzt", "carqc_trackbk_operate:add", "carqc_trackbk_operate:findByPage", "carqc_vehpassTrail_operate:find", "carqc_trackbk_operate:delete"]
      },
      {
        url: "/auditcontrol/dstvehpass/smartSearch",
        permissionList: ["carqc_vehpass_operate:queryHK"]
      },
      {
        url: "/auditcontrol/dstvehpass/map",
        permissionList: ["carqc_vehpassTrail_operate:find"]
      },
      {
        url: "/auditcontrol/dstvehpass/importantcar",
        permissionList: ["carqc_vehicleKey_operate:batchImport", "carqc_vehicleKey_operate:delete", "carqc_vehicleKey_operate:findById", "carqc_vehicleKey_operate:findByPage", "carqc_vehicleKey_operate:exportToExcel", "carqc_vehicleKey_operate:addOrUpdate"]
      },
      {
        url: "/auditcontrol/dstvehpass/electronicfence",
        permissionList: ["base_baseTFence_operate:findByPage", "base_baseTFence_operate:exportToExcel", "base_baseTFence_operate:delete", "base_baseTFence_operate:saveFence", "base_baseTFence_operate:findById"]
      },
      {
        url: "/auditcontrol/dstvehpass/carpass",
        permissionList: ["carqc_vehpass_operate:findByPage"]
      },
      {
        url: "/auditcontrol/carwran/warnLine",
        permissionList: ["carqc_vehpassAtvroute_operate:findByPage", "carqc_vehpassAtvroute_operate:delete", "carqc_monitorVehRoute_operate:getVehRouteInfoByYjxbh", "carqc_vehpassAtvroute_operate:editStatus", "carqc_vehpassAtvroute_operate:editQueryDetail"]
      },
      {
        url: "/auditcontrol/carwran/trackalarm",
        permissionList: ["carqc_trackAlarm_operate:findByPage"]
      },
      {
        url: "/auditcontrol/carwran/integrationEarlyWarnQuery",
        permissionList: ["carqc_trackIntergrated_operate:findByPage"]
      },
      {
        url: "/auditcontrol/carwran/count",
        permissionList: ["carqc_vehpassMonitor_operate:countYjlx"]
      }
    ]
  });
};

const login = options => {
  const body = getBody(options);
  console.log("mock: body", body);
  return builder({
    jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9",
    user: {
      id: "8a948b446f82e6ed016f82ea6f760000",
      username: "admin",
      name: "超级管理员",
      sex: "1",
      identityCard: null,
      usernameLimitTime: "2022-12-07T16:00:00.000+0000",
      passwordLimitTime: "2022-12-07T16:00:00.000+0000",
      isValid: "0",
      isStarter: "0",
      isSuper: "0",
      nickname: "超级管理员",
      email: "hyingreborn@pp.com",
      phone: "18326553560",
      avatar: "/static/admin/userSuper.png",
      lastLoginTime: "2021-01-26T09:15:52.406+0000",
      lastLoginIp: "10.20.11.135",
      lastLoginToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZGVwYXJ0bWVudCI6IjUxMjAwMDAwMDAwMCIsInVzZXIiOnsiaWQiOiI4YTk0OGI0NDZmODJlNmVkMDE2ZjgyZWE2Zjc2MDAwMCIsInVzZXJuYW1lIjoiYWRtaW4iLCJuaWNrbmFtZSI6Iui2hee6p-euoeeQhuWRmCIsImVtYWlsIjoiaHlpbmdyZWJvcm5AcHAuY29tIiwicGhvbmUiOiIxODMyNjU1MzU2MCIsImdsYm1iaCI6IjUxMjAwMDAwMDAwMCIsImdsYm1tYyI6Iui1hOmYs-S6pOitpuaUr-mYnyIsIm5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJzZXgiOiIxIiwiaWRlbnRpdHlDYXJkIjpudWxsLCJsYXN0TG9naW5UaW1lIjoxNjExNjUyNTIwMDAwLCJsYXN0TG9naW5JcCI6IjEwLjIwLjExLjE5MSIsImlzU3VwZXIiOiIwIn0sImlhdCI6MTYxMTY1MjU1MiwiZXhwIjoxNjEyMjU3MzUyfQ.z0M9riRf32PPGCbkiut1TH19QKtE_kJutxLTbarfPVc",
      createdTime: "2020-02-28T09:59:21.000+0000",
      updatedTime: "2021-01-05T08:11:55.000+0000",
      glbmbh: "512000000000",
      glbmmc: "资阳交警支队",
      createUserName: null,
      updateUserName: "admin",
      roleDropDto: null
    }
  });
};

Mock.mock(/\/login\/login/, "post", login);
Mock.mock(/\/menu\/getMenuInfoByUsernameAndAppId/, "get", findNewWlVersionAndSysInfo);
